﻿namespace SharpGym.WinRT.Model
{
    using System;

    public class PressaoArterial : BaseModel
    {
        private const double EPSILON = 0.000001;
        private double _diastolica;
        private RegistroDiario _registroDiario;
        private double _sistolica;

        public virtual double Sistolica
        {
            get { return _sistolica; }
            set
            {
                if (Math.Abs(Sistolica - value) < EPSILON)
                    return;

                _sistolica = value;
                OnPropertyChanged("Sistolica");
            }
        }

        public virtual double Diastolica
        {
            get { return _diastolica; }
            set
            {
                if (Math.Abs(Diastolica - value) < EPSILON)
                    return;

                _diastolica = value;
                OnPropertyChanged("Diastolica");
            }
        }

        public RegistroDiario RegistroDiario
        {
            get { return _registroDiario; }
            set
            {
                _registroDiario = value;
                OnPropertyChanged("RegistroDiario");
            }
        }

        public static bool operator ==(PressaoArterial s1, PressaoArterial s2)
        {
            return s2 != null && (s1 != null && (Math.Abs(s1.Sistolica - s2.Sistolica) < EPSILON &&
                                                 Math.Abs(s1.Diastolica - s2.Diastolica) < EPSILON));
        }

        public static bool operator !=(PressaoArterial s1, PressaoArterial s2)
        {
            return !(s1 == s2);
        }
    }
}